<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Proceso extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->form_data = new stdClass();
        if (!empty($this->session->userdata['nombre'])) {
            $this->form_data->nom = $this->session->userdata['nombre'];
            $this->form_data->ape = $this->session->userdata['apellido'];
            $this->form_data->suc = $this->session->userdata['sucursal'];
            $this->load->helper('navigation');
        } else {
            redirect("acceso");
        }
    }
    
    public function frmapertura() {
              $this->pagina('frmapertura_view', array());
    }
    
     public function registrarApertura(){
        $this->load->model("caja/gasto_model");
        $params = array($this->session->userdata['nombre']." ".$this->form_data->ape = $this->session->userdata['apellido'],$_POST["txtMonto"],$this->session->userdata['idSuc'],$this->session->userdata['sucursal']);
        $this->gasto_model->aperturainsert($params);
        $this->pagina('frmapertura_view', array());
   } 
   public function frmgastosdiarios() {      
        $this->pagina('frmgastosdiarios_view', array());
    }
    
   public function registrarGasto(){
        $this->load->model("caja/gasto_model");
        
        $params = array($_POST["txtMonto"],$_POST["txtMotivo"],$this->session->userdata['nombre']." ".$this->form_data->ape = $this->session->userdata['apellido'],$this->session->userdata['idSuc'],$this->session->userdata['sucursal']);
        $this->gasto_model->gastoinsert($params);
        $this->pagina('frmgastosdiarios_view', array());
   } 
    public function listgastosdiarios() {
          $this->load->model("caja/gasto_model");
        $params = array($this->session->userdata['idSuc']);
        $data['gastos']=$this->gasto_model->gastohoygetall($params);
              $this->pagina('gastosdiarios_view', $data);
    }
    
    public function listcerrarcaja() {
          $this->load->model("caja/gasto_model");
        $params = array($this->session->userdata['idSuc']);
        $data['cierre']=$this->gasto_model->cierregethoy($params);
              $this->pagina('frmcierre_view', $data);
    }
    
    
    private function pagina($vista, $data) {
        $this->load->model("panel_model");
        $menu["caja"] = "active open";
        $user = $this->session->userdata['codigo'];
        $params = array($user,1);
        $menu["menu"] = $this->panel_model->menu($params);
        $this->load->view('estructura/head');
        $this->load->view('estructura/madmin', $menu);
        $this->load->view('intranet/caja/' . $vista, $data);
        $this->load->view('estructura/footer');
    }
    
    
    
}


